/*
 * The client for the student allowing them to enrol in and access module
 * details.
 */

package studentclientejb;

import java.io.*;
import java.net.*;

/**
 * @author 580008769
 */
public class Main {


    // Initialise Variables
    static String serverAddress;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // Declare bufferedreader
        BufferedReader inFromUser = new BufferedReader(
                new InputStreamReader(System.in));

        // Open socket to the server application
        Socket clientSocket = new Socket(serverAddress, 6789);
        DataOutputStream outToServer = new DataOutputStream(
                clientSocket.getOutputStream());
        BufferedReader inFromServer = new BufferedReader(
                new InputStreamReader(clientSocket.getInputStream()));

        // Prompt the user for input
        System.out.println("Enter your message");
        String sentence = inFromUser.readLine();

        // Send the message to the server application
        outToServer.writeBytes(sentence + "\n");

        // Print response from server - close socket.
        System.out.println("FROM SERVER: " + inFromServer.readLine());

        // Close sockets on exit.
        clientSocket.close();
    }

}
